The head positioning of a hard disk drive is very sensitive against disturbances of shock or vibration. Shocks or vibrations that exceed a certain threshold can introduce off-track writes resulting in data loss. It has been proposed to use accelerometers to sense shock and vibration to the hard disk drive. The accelerometers generate a signal which can be used as a feed forward controller to make the disk drive more robust to shocks and vibrations. There are various methods to compensate the head position and to abort a write operation employing an accelerometer. The accelerometer has mechanical force sensing elements with a mechanical resonance. To sense the shock or vibration correctly during normal operation, the resonance frequency of the accelerometer needs to be determined and filtered out using a low pass filter or a notch filter. Typically, this is accomplished by applying a mechanical hammer shock to the accelerometer, for example, through the body of the disk drive and measuring the response of the accelerometer. The accelerometer response should include the mechanical resonance of the accelerometer, which can be measured by a spectrum analyzer and employed to program the low pass filter or notch filter during manufacturing.